<template>
	<om-addpage style="padding-top: 35px;" :menuName="menuName" :busCode="busCode" @formSubmit="formSubmit">
		<om-autoform  ref="autoform" :initConfigData="mainConfigData" :initValue="initValue"></om-autoform>
	</om-addpage>
</template>

<script>
	import dateTimePicker from '@/static/js/dateTimePicker.js';	
	import {
		getUrl,
		confirmModal,
		ptFloat,
		minusF,
		errorModal,
		ignoreHtml
	} from '@/static/js/common.js';
	import {
		hasEditor,
		getEditorTitle,
		getEditor,
		buildFormData,
		formValidation,
		tranferToEditors,
		changeEditor,
		setSubmitSubValue,
		configSelectData,
		hasValue,
		formShowLoading,
		getFormFields,
		formModelLoad,
		getWorkCacheKey
	} from '@/static/js/formUtil.js';
	import urlUtil from '@/static/js/urlUtil.js';
	import moment from '@/static/js/moment.js'
	import { mapState } from 'pinia';
	import {useLoginUserStore} from '@/stores/login-user.js';
	export default {
		computed: {
			...mapState(useLoginUserStore, ['userName', 'userId'])
		},
		provide(){
			return {
				formPage: this
			}
		},
		data(){
			return buildFormData({
				infonameIdCacheKey: 'hr-u-leave-infonameId-cache',
				advanceDateNum: 0,
				canLeaveDate: new Date(),
				leaveReasonInfoLength: 0,
				readDataFlag: false,
				day:'',
				leaveReasonSubIdArr:"",
				editId:''
			})
		},
		methods:{
			getDay(){
				let _that = this
				_that.om.request(
					"dataDict/getIntByCode",
					{
						code:'DD014003001'
					}
				).then(res=>{
					if(res.succeed && res.value){
						_that.$refs.autoform.formdata.advanceDate = res.value
						_that.$refs.autoform.formdata.advanceFlag = true
						_that.$refs.autoform.formdata.advanceFlagName = '√'
					}
				})
			},
			getEntryTrialFlag(posStateCode,id){
				let _that = this
				let formdata = _that.$refs.autoform.formdata
				
				if (posStateCode == "36727") {//入职试用
					formdata.entryTrialFlag = true
					formdata.entryTrialFlagName = '√'
					_that.$refs.autoform.clear("leaveInfo","advanceFlag")
					formdata.advanceDate = _that.advanceDateNum
					_that.leaveDateFunc(new Date(), _that.advanceDateNum)
				}else{
					formdata.entryTrialFlagName = ''
					_that.om.request('/tposition/getSalaryPos', {
						userId:id
					}).then(res => {
						if(res.succeed == true){
							let zd = res.value
							let advanceDateNums = ''
							if(zd && zd.aheadApply){
								formdata.advanceFlag = true
								formdata.advanceFlagName = "√"
								formdata.advanceDate = zd.aheadDay
								advanceDateNums = zd.aheadDay
							}else{
								_that.getDay()
							}
							_that.leaveDateFunc(new Date(), advanceDateNums)
						}else{
							_that.om.toast(res.msg);
						}
					})
				}
			},
			leaveReasonTrim(data){
				let arr = data.split(',');
				let arrjg = arr.filter(function (s) {
				   return s && s.trim();
				});
				let str = arrjg.toString()
				return str
			},
			infonameIdHandle(d){
				let _that = this
				let formdata  = _that.$refs.autoform.formdata
				_that.om.request('/tlApply/verifySame', {
					userId: d.id,
					editId: _that.editId
				}).then(res => { 
					if(res.succeed == true){
						if(res.value){
							_that.om.toast(res.value);
						}else{
							_that.om.request('/temployee/getEmpBasicInfo', {
								userId: d.id
							}).then(res => {
								if(res.succeed == true){
									let sd = res.value
									formdata.infonameId = d.id
									formdata.infoname = d.username
									formdata.sexName = sd.sexName
									formdata.birthdate = sd.birthdate
									formdata.birthPlace = sd.birthPlace
									formdata.highestEduName = sd.highestEduName
									formdata.entrydate = sd.entrydate
									formdata.mobile = sd.mobile
									formdata.areaName = sd.areaName
									formdata.idTypeName = sd.idTypeName
									formdata.idcard = sd.idcard
									formdata.certificateValidDate = sd.certificateValidDate
									formdata.nationName = sd.nationName
									formdata.marriageName = sd.marriageName
									formdata.politicalName = sd.politicalName
									formdata.bloodTypeName = sd.bloodTypeName
									formdata.userno = sd.userno
									formdata.registerCategoryName = sd.registerCategoryName
									formdata.birthaddress = sd.birthaddress
									formdata.currentaddress = sd.currentaddress
									formdata.roleCategoryName = sd.roleCategoryName
									_that.om.request(
										"tinstitution/getInstInfo",
										{
											instId:sd.salaryPosInstId
										}
									).then(res=>{
										_that.$refs.autoform.formdata.instLevelId =  res.value.instcatId
										_that.$refs.autoform.formdata.instLevelName =  res.value.instcatName
									})
								}
							})
							
							_that.om.request('/tworkInfo/getInfo1', {
								userId: d.id
							}).then(res => {
								if(res.succeed == true){
									let sd = res.value
									_that.getEntryTrialFlag(d.posStateCode,d.id)
									let dataList = _that._.cloneDeep(sd)
									if(_that.subEditorObj["workInfo"]){
										_that.subEditorObj["workInfo"].workList = dataList
										_that.$refs.autoform.$set(_that.$refs.autoform.formdata,"workInfo",JSON.stringify(dataList))
										_that.$set(_that.formdata,'workInfo',JSON.stringify(dataList))
										_that.subEditorObj["workInfo"].showAdd = false
										_that.subEditorObj["workInfo"].showDel = false
									}
								}else{
									_that.om.toast(res.msg);
								}
							})
							
							_that.om.request('/employContractList/getContractInfo', {
								userId: d.id
							}).then(res => {
								if(res.succeed == true){
									let sd = res.value
									if(sd.id){
										_that.readDataFlag = true
										formdata.laborTypeCode = sd.contractCategoryCode
										formdata.laborTypeName = sd.contractCategoryName
										formdata.contractTypeId = sd.contractTypeId
										formdata.contractTypeName = sd.contractTypeName
										formdata.laborDate = sd.contractStartDateStr
										formdata.laborEnd = sd.contractEndDateStr
										formdata.laborNum = sd.num
										_that.$refs.autoform.changeEditor("laborRelateInfo","laborTypeCode","type","labelbox")
										_that.$refs.autoform.changeEditor("laborRelateInfo","contractTypeId","type","labelbox")
										_that.$refs.autoform.changeEditor("laborRelateInfo","laborDate","type","labelbox")
										_that.$refs.autoform.changeEditor("laborRelateInfo","laborEnd","type","labelbox")
										_that.$refs.autoform.changeEditor("laborRelateInfo","laborNum","type","labelbox")
									}else{
										_that.readDataFlag = false
										_that.$refs.autoform.clear("laborRelateInfo","laborTypeCode")
										_that.$refs.autoform.clear("laborRelateInfo","contractTypeId")
										_that.$refs.autoform.clear("laborRelateInfo","laborDate")
										_that.$refs.autoform.clear("laborRelateInfo","laborEnd")
										_that.$refs.autoform.clear("laborRelateInfo","laborNum")
										_that.$refs.autoform.changeEditor("laborRelateInfo","laborTypeCode","type","selectbox")
										_that.$refs.autoform.changeEditor("laborRelateInfo","contractTypeId","type","selectbox")
										_that.$refs.autoform.changeEditor("laborRelateInfo","laborDate","type","datebox")
										_that.$refs.autoform.changeEditor("laborRelateInfo","laborEnd","type","datebox")
										_that.$refs.autoform.changeEditor("laborRelateInfo","laborNum","type","numberbox")
									}
								}else{
									_that.om.toast(res.msg);
								}
							})
							
							_that.om.request('/tlApply/findInstDirectorData', {
								userId: d.id
							}).then(res => {
								if(res.succeed == true){
									let sd = res.value
									let dataList = _that._.cloneDeep(sd)
									if(_that.subEditorObj["instDirectorInfo"]){
										_that.subEditorObj["instDirectorInfo"].workList = dataList
										_that.$refs.autoform.$set(_that.$refs.autoform.formdata,"instDirectorStr",JSON.stringify(dataList))
										_that.$set(_that.formdata,'instDirectorStr',JSON.stringify(dataList))
										_that.subEditorObj["instDirectorInfo"].showAdd = false
										_that.subEditorObj["instDirectorInfo"].showDel = false
									}
								}else{
									_that.om.toast(res.msg);
								}
							})
							
							_that.om.request('/tlApply/findBusinessDirectorData').then(res => {
								if(res.length>0){
									let sd = res								
									if(sd.length>0){
										let proArr = []
										for(let i=0; i<sd.length; i++){
											proArr.push(_that.om.request('tlApply/findBusinessDirectorInstList', { userId: sd[i].userId }))
										}
										
										Promise.all(proArr).then(res=>{
											for(let i=0; i<sd.length; i++){
												sd[i].businessDirectorId = sd[i].userId
												sd[i].businessDirectorName = sd[i].userName
												sd[i].interviewFlag = ''
												sd[i].interviewFlagName = ''
												sd[i].opinion = ''
												sd[i].instId = res[i][0].id
												sd[i].instName = res[i][0].instName
											}
											
											let dataList = _that._.cloneDeep(sd)
											if(_that.subEditorObj["businessDirectorInfo"]){
												_that.subEditorObj["businessDirectorInfo"].workList = dataList
												_that.$refs.autoform.$set(_that.$refs.autoform.formdata,"businessDirectorStr",JSON.stringify(dataList))
												_that.$set(_that.formdata,'businessDirectorStr',JSON.stringify(dataList))
												_that.subEditorObj["businessDirectorInfo"].showAdd = false
												_that.subEditorObj["businessDirectorInfo"].showDel = false
											}
										})
									}else{
										_that.om.toast(res.msg);
									}
								}
							})
						}
					}else{
						_that.om.toast(res.msg);
					}
				})
			},
			getDateStr(initData,addDayCount) {   
			   let dd = new Date(initData);  
			   dd.setDate(dd.getDate()+addDayCount);
			   let y = dd.getFullYear();   
			   let m = (dd.getMonth()+1)<10?"0"+(dd.getMonth()+1):(dd.getMonth()+1);
			   let d = dd.getDate()<10?"0"+dd.getDate():dd.getDate();
			   return y+"-"+m+"-"+d;   
			},
			leaveDateFunc(initData, advanceDateNum){
				let _that = this
				let flagDate = initData
				if (advanceDateNum) {
				    flagDate = _that.getDateStr(flagDate, advanceDateNum);
				}else{
					flagDate = _that.moment(flagDate).format("YYYY-MM-DD");
				}
				_that.$refs.autoform.changeEditor("leaveInfo","leaveDate","type","datebox")
				 _that.canLeaveDate = flagDate
			},
			
			onSelectLeaveDay(data){
				let _that = this
				_that.om.request(
					"dataDict/getIntByCode",
					{
						code:'DD014003008'
					}
				).then(res=>{
					let title =  _that.$refs.autoform.getEditorTitle("leaveInfo","leaveDate")
					let posName = ""
					let day = "30"
					if(_that.$refs.autoform.formdata.advanceDate){
						day = _that.$refs.autoform.formdata.advanceDate
					}
					for(let item of _that.subEditorObj["workInfo"].workList){
						if(item.salaryPosFlagStr){
							posName = item.posName
						}
					}
					if(res.value == 1){
						if(moment(data).isBefore(moment().add(Number(day),'days'))){
							errorModal(_that,"提示信息","任职岗位("+posName+")要求提前"+day+"天提出离职申请，拟离职日期不能早于"+moment().add(Number(day),'days').format('MM-DD')+"，请重新选择日期！",()=>{
								_that.$refs.autoform.clear("leaveInfo","leaveDate")
							})
						}
					}else{
						if(moment(data).isBefore(moment().add(Number(day),'days'))){
							confirmModal(_that,"提示信息","任职岗位("+posName+")要求提前"+day+"天提出离职申请，您确认要提前离职吗？",
							()=>{},
							()=>{
								_that.$refs.autoform.clear("leaveInfo","leaveDate")
							})
						}
					}
				})
			},
			onSelectLaborTypeName(data){
				let _that = this
				if(data.code == 37690){
					_that.$refs.autoform.changeEditor("laborRelateInfo","laborEnd","type","labelbox")
				}else{
					_that.$refs.autoform.changeEditor("laborRelateInfo","laborEnd","type","datebox")
				}
			},
			formSubmit(){
				let _that = this
				_that.formdata.readDataFlag = _that.readDataFlag
				let leaveReasonIdArr = []
				for(let i=0; i<_that.leaveReasonInfoLength; i++){
					if(_that.$refs.autoform.formdata['leaveReasonSubId'+i]){
						leaveReasonIdArr.push(_that.$refs.autoform.formdata['leaveReasonSubId'+i])
					}
				}
				_that.formdata.objStr = leaveReasonIdArr
				if(_that.formdata.objStr){
					if(_that.checkedit){
						_that.om.formSave('commonForm/doCheckOrApproveUpdate',_that.formdata,_that)
					}else{
						if(_that.edit){
							_that.om.formSave('tlApply/addTlApply',_that.formdata,_that)
						}else{
							_that.om.request(
								"posBusiAuth/verifyOne",
								{
									busCode:_that.busCode,
									isNew:true
								}
							).then(res=>{
								if(res.succeed){
									_that.om.formSave('tlApply/addTlApply',_that.formdata,_that)
								}else{
									_that.om.toast(res.msg)
								}
							})
						}
					}
				}else{
					_that.om.toast('离职事由中至少选择一项');
				}
			},
			initLoad(options){
				let _that = this
				let ajaxArr = []
				var fileId = options.fileId
				let obj = {
					userId:_that.userId
				}
				ajaxArr.push({
					url:"tlApply/getReasonList"
				},{
					url:"dictZero/getListByCode",
					param:{
						code:"37689"
					}
				},{
					url:"dataDict/getIntByCode",
					param:{
						code:"DD014003005"
					}
				},{
					url:"dictSource/loadCombo",
					param:{
						sourceId: "289",
						categoryId: "7172"
					}
				})
				if(options.checkedit){
					_that.checkedit = options.checkedit
				}
				if(fileId){
					_that.editId = fileId
					ajaxArr.push({
						url:"tlApply/getInfo",
						param:{
							id:fileId
						}
					})
				}
				formModelLoad(ajaxArr,function(res,mainData){
					let leaveReasonInfoEditors = res[0].value
					_that.leaveReasonInfoLength = leaveReasonInfoEditors.length
					if(leaveReasonInfoEditors.length>0){
						for(let i=0; i<leaveReasonInfoEditors.length; i++){
							let obj = {};
							obj.checkedit = null
							obj.data = configSelectData(leaveReasonInfoEditors[i].children, "id", "text", true),
							obj.editReadonly = null
							obj.isfull = null
							obj.max = ''
							obj.min = ''
							obj.nameField = 'leaveReasonSubName'+i
							obj.required = false
							obj.title = leaveReasonInfoEditors[i].text
							obj.type = 'checkbox'
							obj.valueField = 'leaveReasonSubId'+i
							mainData[5].editors.push(obj)
						}
						
					}		
					changeEditor("userInfo","infonameId",{
						link:"../../public/pageSearch/pageSearch",
						"linkParam": {
							other:JSON.stringify({
								userId: _that.userId
							}),
							namefield:'userSalaryPosInstName',
							extrafield: 'parentInstName',
							searchfield:"q",
							initload:true,
							url:'tlApply/getEmpList',
							cachename:_that.infonameIdCacheKey,
							placeholder:"请输入姓名"
						}
					},null,mainData)
					
					changeEditor("laborRelateInfo", "laborTypeCode", "data", configSelectData(res[1],"id","dicname"),mainData)
					changeEditor("laborRelateInfo", "contractTypeId", "data", configSelectData(res[3],"id","text"),mainData)
					
					_that.advanceDateNum = res[2].value
					
					if(_that.subEditorObj["workInfo"]){
						let att = {
							showAdd:false,
							showArrow:false,
							showDel:false
						}
						let configData = _that.subConfigData["workInfo"]
						if(hasEditor("workInfo","posName",configData)){
							let title = getEditorTitle("workInfo","posName",configData)
							att.titleTemplate = title+":<%= posName %>"
						}
						if(hasEditor("workInfo","salaryPosFlagStr",configData)){
							let title = getEditorTitle("workInfo","salaryPosFlagStr",configData)
							att.titleTemplate = att.titleTemplate+"<%= salaryPosFlagStr %>"
						}
						if(hasEditor("workInfo","parentUserName",configData)){
							let title = getEditorTitle("workInfo","parentUserName",configData)
							att.subtitle1Template = title+":<%= parentUserName %>"
						}
						if(hasEditor("workInfo","instShort",configData)){
							let title = getEditorTitle("workInfo","instShort",configData)
							att.subtitle1Template = att.subtitle1Template +'|'+  title +":<%= instShort %>"
						}
						if(hasEditor("workInfo","parentInst",configData)){
							let title = getEditorTitle("workInfo","parentInst",configData)
							att.subtitle2Template = title +":<%= parentInst %>"
						}
						if(hasEditor("workInfo","salaryWay",configData)){
							let title = getEditorTitle("workInfo","salaryWay",configData)
							att.subtitle2Template = att.subtitle2Template +'|'+ title +":<%= salaryWay %>"
						} 
						changeEditor("workInfo","workInfo",att,mainData)
					}
					// changeEditor("workInfo", "workInfo", {
					// 	titleTemplate: "  <%= posName %>",
					// 	subtitle1Template: "<%= instShort %>",
					// 	subtitle2Template: "<%= '计酬方式：'+ (salaryWay ? salaryWay : '') %>"
					// }, null, mainData)
					if(_that.subEditorObj["instDirectorInfo"]){
						changeEditor("instDirectorInfo", "instDirectorStr", {
							showAdd:false,
							showDel:false,
							titleTemplate: "  <%= instDirectorName %>",
							subtitle1Template: "<%= '面谈：'+ (interviewFlagName ? interviewFlagName : '') %>"
						}, null, mainData)
					}
					if(_that.subEditorObj["businessDirectorInfo"]){
						changeEditor("businessDirectorInfo", "businessDirectorStr", {
							showAdd:false,
							showDel:false,
							titleTemplate: "  <%= businessDirectorName %>",
							subtitle1Template: "<%= '面谈：'+ (interviewFlagName ? interviewFlagName : '') %>"
						}, null, mainData)
					}
					
					// _that.subEditorObj["workInfo"].showAdd = false
					// _that.subEditorObj["workInfo"].showDel = false
					
					
					_that.$nextTick(function(){
						_that.$refs.autoform.initSelectIndex("laborRelateInfo", "laborTypeCode")
						_that.$refs.autoform.initSelectIndex("laborRelateInfo", "contractTypeId")
					})
					
					if(fileId){
						var fieldArr = getFormFields(mainData)
						fieldArr.push("id")
						
						for(let i in  res[4].value.tlApply){
							if(fieldArr.includes(i)){
								_that.$refs.autoform.$set(_that.$refs.autoform.formdata,i,res[4].value.tlApply[i])
								_that.$set(_that.formdata,i,res[4].value.tlApply[i])
							}
						}
						_that.readDataFlag = res[4].value.tlApply.readDataFlag
						
						for(let i in  res[4].value.temployeeResponse){
							if(fieldArr.includes(i)){
								_that.$refs.autoform.$set(_that.$refs.autoform.formdata,i,res[4].value.temployeeResponse[i])
								_that.$set(_that.formdata,i,res[4].value.temployeeResponse[i])
							}
						}
						
						for(let i in  res[4].value.tuserInfo){
							if(fieldArr.includes(i)){
								_that.$refs.autoform.$set(_that.$refs.autoform.formdata,i,res[4].value.tuserInfo[i])
								_that.$set(_that.formdata,i,res[4].value.tuserInfo[i])
							}
						}
				
						let dataList = _that._.cloneDeep(res[4].value.tworkInfos)
						_that.subEditorObj["workInfo"].workList = dataList
						_that.$refs.autoform.$set(_that.$refs.autoform.formdata,"workInfo",JSON.stringify(dataList))
						_that.$set(_that.formdata,'workInfo',JSON.stringify(dataList))
						delete res[4].value.tworkInfos
						
						let dataList1 = _that._.cloneDeep(res[4].value.instDirectorList)
						if(_that.subEditorObj["instDirectorInfo"]){
							_that.subEditorObj["instDirectorInfo"].workList = dataList1
							_that.$refs.autoform.$set(_that.$refs.autoform.formdata,"instDirectorStr",JSON.stringify(dataList1))
							_that.$set(_that.formdata,'instDirectorStr',JSON.stringify(dataList1))
							delete res[4].value.instDirectorList
						}
						
						
						let dataList2 = _that._.cloneDeep(res[4].value.businessDirectorList)
						if(_that.subEditorObj["businessDirectorInfo"]){
							_that.subEditorObj["businessDirectorInfo"].workList = dataList2
							_that.$refs.autoform.$set(_that.$refs.autoform.formdata,"businessDirectorStr",JSON.stringify(dataList2))
							_that.$set(_that.formdata,'businessDirectorStr',JSON.stringify(dataList2))
							delete res[4].value.businessDirectorList
						}
						
						
						_that.$refs.autoform.formdata.leaveReasonId = res[4].value.dataList
						for(let i=0; i<_that.leaveReasonInfoLength; i++){
							_that.$refs.autoform.formdata['leaveReasonSubId'+i] = ','
							_that.$refs.autoform.formdata['leaveReasonSubName'+i] = ','
						}
						if(_that.$refs.autoform.formdata.leaveReasonId){
							let leaveReasonIdArr = _that.$refs.autoform.formdata.leaveReasonId.map(e=>e.leaveReasonId);
							_that.leaveReasonSubIdArr = leaveReasonIdArr
							for(let i=0; i<leaveReasonIdArr.length; i++){
								for(let r=0; r<_that.leaveReasonInfoLength; r++){
									if(res[0].value[r].children.length>0){
										for(let t=0; t<res[0].value[r].children.length; t++){
											if(leaveReasonIdArr[i] == res[0].value[r].children[t].id){
												_that.$refs.autoform.formdata['leaveReasonSubId'+r] = _that.$refs.autoform.formdata['leaveReasonSubId'+r] + leaveReasonIdArr[i] + ',';
												_that.$refs.autoform.formdata['leaveReasonSubName'+r] = _that.$refs.autoform.formdata['leaveReasonSubName'+r] + res[0].value[r].children[t].text + ',';
												_that.$refs.autoform.$set(res[0].value[r].children[t], "checked", true)
											}
										}
									}
								}
							}
						}
						for(let i=0; i<_that.leaveReasonInfoLength; i++){
							_that.$refs.autoform.formdata['leaveReasonSubId'+i] = _that.leaveReasonTrim(_that.$refs.autoform.formdata['leaveReasonSubId'+i])
							_that.$refs.autoform.formdata['leaveReasonSubName'+i] = _that.leaveReasonTrim(_that.$refs.autoform.formdata['leaveReasonSubName'+i])
						}
						
						_that.formdata.id = fileId
						_that.$refs.autoform.formdata.id = fileId
						
						_that.$nextTick(function(){
							if(_that.readDataFlag){
								_that.$refs.autoform.changeEditor("laborRelateInfo","laborTypeCode","type","labelbox")
								_that.$refs.autoform.changeEditor("laborRelateInfo","contractTypeId","type","labelbox")
								_that.$refs.autoform.changeEditor("laborRelateInfo","laborDate","type","labelbox")
								_that.$refs.autoform.changeEditor("laborRelateInfo","laborEnd","type","labelbox")
								_that.$refs.autoform.changeEditor("laborRelateInfo","laborNum","type","labelbox")
							}else{
								_that.$refs.autoform.changeEditor("laborRelateInfo","laborTypeCode","type","selectbox")
								_that.$refs.autoform.changeEditor("laborRelateInfo","contractTypeId","type","selectbox")
								_that.$refs.autoform.changeEditor("laborRelateInfo","laborDate","type","datebox")
								_that.$refs.autoform.changeEditor("laborRelateInfo","laborEnd","type","datebox")
								_that.$refs.autoform.changeEditor("laborRelateInfo","laborNum","type","numberbox")
								_that.$refs.autoform.initSelectIndex("laborRelateInfo", "laborTypeCode")
								_that.$refs.autoform.initSelectIndex("laborRelateInfo", "contractTypeId")
							}	
						})
					}
					if(_that.checkedit){
						let jgarr = res[4].value.dataListStr.split('</br>')
						if(mainData[5].editors.length>0 && jgarr.length>0){
							for(let i=0; i<mainData[5].editors.length; i++){
								for(let r=0; r<jgarr.length; r++){
									let num = mainData[5].editors[i].title.length;
									if(mainData[5].editors[i].title == jgarr[r].substring(0,num)){
										_that.$refs.autoform.formdata[mainData[5].editors[i].nameField] = jgarr[r].substring(num+1,jgarr[r].length)
									}
								}
							}
						}
					}
					if(!fileId){
						_that.$nextTick(function(){
							if(_that.userId){
								_that.om.request(
									"tlApply/getEmpList",
									{
										userId:_that.userId,
										firstUserId:_that.userId,
										rows:20,
										page:1,
									}
								).then(data=>{
									if(data.rows[0]){
										var data=data.rows[0]
										_that.infonameIdHandle(data)
									}
								})
							}
						})
					}
				},options)
		},		
		onShow(){
			let _that = this
			for (let fieldId in _that.subEditorObj) {
				let editor = _that.subEditorObj[fieldId];
				uni.getStorage({
					key: getWorkCacheKey(fieldId),
					success: function(res) {
						editor.workList = res.data;
						uni.removeStorage({
							key: getWorkCacheKey(fieldId)
						});
					}
				});
			}
			if(_that.$refs.autoform){
				uni.getStorage({
					key: _that.infonameIdCacheKey,
					success: function(res) {
						if(res.data){
							_that.infonameIdHandle(res.data)
							uni.removeStorage({
								key: _that.infonameIdCacheKey
							});
						}
					},
				});
			}
		},	
		onLoad(options){
			this.initLoad(options)
		},	
			
		},
	}
</script>

<style>
</style>
